// 用户信息模型
class UserInfo {
  final int userId;
  final String userName;
  final String nickName;
  final int deptId;
  final String email;
  final String phonenumber;
  final String sex;
  final String avatar;
  final String status;

  UserInfo({
    required this.userId,
    required this.userName,
    required this.nickName,
    required this.deptId,
    required this.email,
    required this.phonenumber,
    required this.sex,
    required this.avatar,
    required this.status,
  });

  factory UserInfo.fromJson(Map<String, dynamic> json) {
    return UserInfo(
      userId: json['userId'] ?? 0,
      userName: json['userName'] ?? '',
      nickName: json['nickName'] ?? '',
      deptId: json['deptId'] ?? 0,
      email: json['email'] ?? '',
      phonenumber: json['phonenumber'] ?? '',
      sex: json['sex'] ?? '0',
      avatar: json['avatar'] ?? '',
      status: json['status'] ?? '0',
    );
  }
  
  Map<String, dynamic> toJson() {
    return {
      'userId': userId,
      'userName': userName,
      'nickName': nickName,
      'deptId': deptId,
      'email': email,
      'phonenumber': phonenumber,
      'sex': sex,
      'avatar': avatar,
      'status': status,
    };
  }
}

// 用户完整信息（包括角色和权限）
class UserInfoResponse {
  final UserInfo user;
  final List<String> roles;
  final List<String> permissions;

  UserInfoResponse({
    required this.user,
    required this.roles,
    required this.permissions,
  });

  factory UserInfoResponse.fromJson(Map<String, dynamic> json) {
    return UserInfoResponse(
      user: UserInfo.fromJson(json['user']),
      roles: List<String>.from(json['roles'] ?? []),
      permissions: List<String>.from(json['permissions'] ?? []),
    );
  }
  
  Map<String, dynamic> toJson() {
    return {
      'user': user.toJson(),
      'roles': roles,
      'permissions': permissions,
    };
  }
} 